package org.redswallow.util;

import java.util.Enumeration;
import java.util.Map;
import java.util.Vector;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;

public class ParameterRequestWrapper extends HttpServletRequestWrapper {

	private Map<String, String[]> params;
	
	public ParameterRequestWrapper(HttpServletRequest request, Map<String, String[]> newParams) {
		super(request);

		params = newParams;
	}
	
	public Map<String, String[]> getParameterMap() {
		return params;
    }
 
    public Enumeration<String> getParameterNames() {
        Vector<String> l = new Vector<String>(params.keySet());
        
        return l.elements();
    }
 
    public String[] getParameterValues(String name) {
        return params.get(name);
    }
 
    public String getParameter(String name) {
    	String[] values = params.get(name);
        return (values==null||values.length==0)?null:values[0];
    }

}
